#include "MyDate.h"

void MyDate::Print()
{
	cout << _year << " " << _month << " " << _day << endl;
}

bool MyDate::operator==(MyDate& d)
{
	if (d._year == _year &&
		d._month == _month && d._day == _day)
		return true;
	return false;
}

bool MyDate::operator!=(MyDate& d)
{
	return !(*this == d);
}

bool MyDate::operator>=(MyDate& d)
{
	return (*this == d || *this > d);
}

bool MyDate::operator<=(MyDate& d)
{
	return !(*this > d);
}

bool MyDate::operator<(MyDate& d)
{
	return !(*this >= d);
}

bool MyDate::operator>(MyDate& x)
{
	//if (_year > x._year)
	//	return true;
	//if (_year == x._year && _month > x._month)
	//	return true;
	//if (_year == x._year && _month == x._month && _day > x._day)
	//	return true;
	if (_year > x._year ||
		_year == x._year && _month > x._month ||
		_year == x._year && _month == x._month && _day > x._day)
		return true;
	return false;
}

MyDate MyDate::operator+(int day)
{
	//MyDate ret(*this);
	//ret._day += day;	
	//while (ret._day > GetMonthDay(ret._year, ret._month))
	//{
	//	ret._day -= GetMonthDay(ret._year, ret._month);
	//	ret._month++;
	//	if (ret._month == 13)
	//	{
	//		ret._year++;
	//		ret._month = 1;
	//	}
	//}
	//return ret;
	MyDate ret(*this);
	return ret += day;
}

MyDate& MyDate::operator+=(int day)
{
	//*this = *this + day;
	//return *this;
	_day += day;
	while (_day > GetMonthDay(_year, _month))
	{
		_day -= GetMonthDay(_year, _month);
		_month++;
		if (_month == 13)
		{
			_year++;
			_month = 1;
		}
	}
	return *this;
}

MyDate& MyDate::operator++()
{
	*this += 1;
	return *this;
}

MyDate MyDate::operator++(int)
{
	MyDate tmp(*this);
	*this += 1;
	return tmp;
}


